package aryn.framework.utilities;

import java.util.concurrent.ThreadLocalRandom;

public class Util {

private static ThreadLocalRandom rnd = ThreadLocalRandom.current();
	
	public static boolean randomBoolean() {
		return rnd.nextBoolean();
	}

	public static int randomInt(int min, int max) {
		return rnd.nextInt(min, max);
	}

	public static long randomLong(long min, long max) {
		return rnd.nextLong(min, max);
	}

	public static double randomDouble(double min, double max) {
		return rnd.nextDouble(min, max);
	}

	public static double randomGaussian() {
		return rnd.nextGaussian();
	}

	public static boolean mouseBound(int targetX, int targetY, int x1, int y1, int x2, int y2) {
		return targetX >= x1 && targetX <= x2 && targetY >= y1 && targetY <= y2;
	}

	public static int findFirstNull(Object[] array) {
		for(int i = 0; i < array.length; i++)
			if(array[i] == null)
				return i;
		return -1;
	}
	
	public static int findFirstNotNull(Object[] array) {
		for(int i = 0; i < array.length; i++)
			if(array[i] != null)
				return i;
		return -1;
	}
	
	public static int findLastNotNull(Object[] array) {
		for(int i = array.length - 1; i >= 0; i++)
			if(array[i] != null)
				return i;
		return -1;
	}

}
